package www.sofn.com.accounts;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import www.sofn.com.accounts.domain.vo.WeChartMemberInfoVO;
import www.sofn.com.domain.R;

@RestController
@Tag(name = "账号管理")
public class AccountsController {
    @Resource
    private AccountsService accountsService;

    /**
     * 微信用户登陆
     * @param code
     * @return
     */
    @Operation(summary = "微信登录")
    @GetMapping("/we_chat_login")
    public R<String> weChatLogin(@RequestParam(value = "code",required = true) String code) {
        return  R.ok( accountsService.weChatLogin(code));
    }

    @GetMapping("member_info")
    @Operation(summary = "获取会员信息")
    public R<WeChartMemberInfoVO> getMemberInfo() {
        return R.ok(accountsService.getPersonal());
    }


    @GetMapping("/generate_command")
    @Operation(summary = "生成口令")
    public R<String> generateCommand() {
        //生成口令
       return  R.ok(accountsService.generateCommand());
    }


    @GetMapping("/build_relation/{command}")
    @Operation(summary = "绑定关系")
    public R<String> buildRelation(@PathVariable(value = "command")String command) {
        //生成口令
        accountsService.buildRelation(command);
        return  R.ok();
    }


}
